package day0721;

import javax.swing.*;
import java.util.ArrayList;

public class Test4 {
    public static void main(String[] args) {
        ArrayList<String> through = new ArrayList<>();
        through.add("AA");
        through.add("CC");
        through.add("FF");
        through.add("HH");


        String ele="CC";
        System.out.println(through.size());


        int index=-1;
        String same="no";
        for (int i = 0; i < 4; i++) {
          // System.out.println(ele+"---"+through.get(i));
            if(ele.equals(through.get(i))){
                index=i;
                same="yes";
                break;
            }
        }
        if(same.equals("yes")){
            through.add(index, ele);
        }else{
            through.add(ele);
        }


        System.out.println(through.toString());

       // System.out.println(through);
    }
}
